@extends('admin.layouts.master')

@section('pagecss')
<link rel="stylesheet" type="text/css" href="/admin/assets/bootstrap-datepicker/css/datepicker.css" />
@endsection

@section('content')

<div class="row aw-list">
	<div class="col-lg-12">
		<section class="panel aw-content">
			<header class="panel-heading">通用价格调整</header>
			<div class="aw-mt20 overflow-hidden">
				<div class="col-sm-6 col-md-4 form-group overflow-hidden">
					<div class="col-xs-4 aw-p0 aw-list-input-title">店面：</div>
					<div class="col-xs-8 aw-p0">
						<select placeholder="请选择店面" id="store_id" name="store_id" v-model="form.store_id" :value="form.store_id" class="form-control">
							<option value="0">全部</option>
							<option v-for="(list,key) in list_store" :value="list.id">@{{list.store_name}}</option>
						</select>
					</div>
				</div>
				<div class="col-sm-6 col-md-4 form-group overflow-hidden">
					<div class="col-xs-4 aw-p0 aw-list-input-title">场地类型：</div>
					<div class="col-xs-8 aw-p0">
						<select placeholder="请选择店面" id="type" name="type" v-model="form.type" :value="form.type" class="form-control">
							<option value="0">全部</option>
							<option v-for="(list,key) in list_type" :value="list.id">@{{list.type_text}}</option>
						</select>
					</div>
				</div>
			</div>
			<div v-for="(list,key) in lists">
			<header class="panel-heading">@{{list.storefront_name}} @{{list.type_text}} <span v-if="list.program==1">规则一 07:00开始规则</span><span v-if="list.program==2">规则二 08:00开始规则</span></header>
			<ul class="aw-mt20 aw-overflow-hidden aw-field-time-list">
				<li class="col-sm-4 col-md-3 col-lg-2 aw-field-time-list-li aw-field-pirce-li" v-for="(li,key_li) in list.list">
					<div class="aw-field-time-li open">
						<p>@{{li.start_time}}-@{{li.end_time}}</p>
						<input type="text" class="form-control aw-text-center aw-mt10" v-model="li.price" :value="li.price">
						<a class="btn btn-gules btn-sm aw-mt10" v-on:click="Save_Price(key,key_li)">修改</a>
					</div>
				</li>
			</ul>
			</div>
			<div class="aw-text-center aw-list-null" v-if="lists.length==0">暂无场地</div>
			</div>
		</section>
	</div>
</div>

@section('pagejs')
@parent

<!--日期插件-->
<script type="text/javascript" src="/admin/js/ga.js"></script>
<script type="text/javascript" src="/admin/assets/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>

<script type="text/javascript">
var MJS_URLArry=URLArry;
var Get_form={
	page_id:25,type:0,store_id:0
}
$.extend(Get_form,MJS_URLArry);
var AD_list={
	api:'/adminapi/field/prices',
	form_data:Get_form,
	tips:false,
}
var AD_list_store={
	api:'/adminapi/storefront/list',
	form_data:{page_num:100},
	tips:false,
}
var Ajax_Vue_Fun_Store=function(vue_data){
	console.log('Data_Vue123')
	console.log(vue_data)
	var Data_Vue={
		lists:{},
		list_store:vue_data.list,
		list_type:Data_field_type_list,
		form:Get_form,
	}
	vm=new Vue({
		el:'#Vue-Body',
		data:Data_Vue,
		methods:{
			List_Search:function(){
				AD_list.form_data=vm.form;
				getData(AD_list,Ajax_Vue_Fun)
				URL_Make(vm.form)
			},Save_Price:function(key,key_li){
				console.log(key)
				console.log(key_li)
				var Lists_form=this.lists[key].list[key_li];
				Lists_form.store_id=Lists_form.storefront_id;
				console.log(Lists_form)
				var AD_price={
					api:'/adminapi/field/price-save',
					form_data:Lists_form,
					tips:'通用价格修改成功',
				}
				postData(AD_price)
			}
		},watch:{
	        'form.store_id':function(val,oldval){
	            console.log('门店改变')
	            console.log(val,oldval)
	            this.List_Search()
	        },'form.type':function(val,oldval){
	            console.log('球场类型改变')
	            console.log(val,oldval)
	            this.List_Search()
	        },
    	}	
	})
//	if(MJS_URLArry.type < 0){
//		vm.form.store_id=$('#store_id option:eq(0)').val()
//		vm.form.type=$('#type option:eq(0)').val()
//	}
	vm.List_Search()
}
var Ajax_Vue_Fun=function(vue_data){
	vm.lists=vue_data;
}
getData(AD_list_store,Ajax_Vue_Fun_Store)
</script>
@endsection

@endsection

